package com.yuzhyn.hiops.app.application.controller.web;

import com.yuzhyn.hiops.app.application.service.SysMenuService;
import com.yuzhyn.hiops.common.model.SysMenuTree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Controller
public class WebController {

    @Autowired
    SysMenuService sysMenuService;

    @GetMapping({"/index", "/"})
    public String index(Model model) {
        List<SysMenuTree> trees = sysMenuService.getMenuTree("");

        model.addAttribute("menus", trees);
        model.addAttribute("msg", "首页啊");
        return "index";
    }

    @GetMapping("/webx/{function}")
    String def(@PathVariable String function) {
        return "webx/" + function;
    }

    @GetMapping("/web/{path}/{page}")
    String def(@PathVariable String path, @PathVariable String page) {
        return path + "/" + page;
    }
}
